from PyQt5.Qt import *

import sys



class Example(QWidget):

    def __init__(self):
        super().__init__()

        self.initUI()


    def initUI(self):

        self.setGeometry(300, 300, 400, 300)
        self.setWindowTitle('附件物理文件检查工具')

        # 页面初始化
        # 基础面板位置
        self.base_widget = QWidget(self)
        # print(self.parent().width(), self.parent().height())
        self.base_widget.setGeometry(20, 50, self.width() - 20, self.height() - 50)

        # 第一行 ---------------------------------------------------
        self.ziliao_label = QLabel(text='请输入资料类型编码：')
        self.ziliao_label.setFixedWidth(120)
        self.ziliao_input = QLineEdit()
        self.ziliao_input.setFixedWidth(200)

        row0 = QHBoxLayout()
        row0.addWidget(self.ziliao_label)
        row0.addWidget(self.ziliao_input)

        row0.addStretch(30)  # 站位分割

        # 第二行 ---------------------------------------------------
        self.picihao_label = QLabel(text='请输入批次号：')
        self.picihao_label.setFixedWidth(120)
        self.picihao_input = QLineEdit()
        self.picihao_input.setFixedWidth(200)

        row1 = QHBoxLayout()
        row1.addWidget(self.picihao_label)
        row1.addWidget(self.picihao_input)

        row1.addStretch(1)  # 站位分割

        # 第三行 ---------------------------------------------------
        self.search_btn = QPushButton('开始检查')
        self.search_btn.clicked.connect(self.search)

        row2 = QHBoxLayout()
        row2.addWidget(self.search_btn)

        row2.addStretch(1)  # 站位分割

        # 第四行 ---------------------------------------------------
        self.line1 = QLabel('-------------------------------------------------------')
        row3 = QHBoxLayout()
        row3.addWidget(self.line1)
        row3.addStretch(1)  # 站位分割

        # 第五行 ---------------------------------------------------
        self.shuoming = QLabel('ps:没有物理文件的附件基本信息会保存在当前路径下的excel中')
        row4 = QHBoxLayout()
        row4.addWidget(self.shuoming)
        row4.addStretch(1)  # 站位分割


        # 行插入列，并调整间隔 ---------------------------------------------------
        vbox = QVBoxLayout()
        vbox.addLayout(row0)
        vbox.addStretch(1)  # 站位分割
        # vbox.addLayout(rown)
        # vbox.addStretch(2)  # 站位分割
        vbox.addLayout(row1)
        vbox.addStretch(2)  # 站位分割
        vbox.addLayout(row2)
        vbox.addStretch(2)  # 站位分割
        vbox.addLayout(row3)
        # vbox.addStretch(1)  # 站位分割
        vbox.addLayout(row4)
        vbox.addStretch(2)  # 站位分割

        self.base_widget.setLayout(vbox)

    def search(self):
        ziliao = self.ziliao_input.text()
        picihao = self.picihao_input.text()
        # print(ziliao, picihao)
        # if not ziliao or not picihao:
        #     info_box = QMessageBox(QMessageBox.Warning, 'Message', '输入框为空')
        #     info_box.exec_()
        #     # info_box.show()



    # def closeEvent(self, event):
    #
    #     reply = QMessageBox.question(self, 'Message',
    #                                  "Are you sure to quit?", QMessageBox.Yes |
    #                                  QMessageBox.No, QMessageBox.No)
    #
    #     if reply == QMessageBox.Yes:
    #         event.accept()
    #     else:
    #         event.ignore()

if __name__ == '__main__':

    app = QApplication(sys.argv)

    ex = Example()
    ex.show()

    sys.exit(app.exec_())